<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../../common/meta.jsp"%>
		<script type="text/javascript">

$(function() {
	//给日历提示时间加上默认日期
	var now = new Date();
	var ny = now.getFullYear();
	var nm = now.getMonth() + 1;
	var nd = now.getDate();
	var nh = now.getHours();
	if (nh < 10) {
		nh = "0" + nh;
	}
	var nmm = now.getMinutes();
	if (nmm < 10) {
		nmm = "0" + nmm;
	} 
	var today = ny + "-" + nm + "-" + nd + " " + nh + ":" + nmm ;
	$("#markDate").val(today);

	//是否显示在日历上
	$("#isView").change(function() {
		if ($(this).attr("checked")) {
			$("#markDiv").show();
		} else {
			$("#markDiv").hide();
		}
	});

	//设置表单验证
	var addForm = $("#addForm").validate( {
		rules : {
			affairItem : {
				required : true,
				rangelength : [ 2, 20 ]
			},
			markDate : {
				required : function() {
					return $("#isView").attr("checked") == "checked";
				}
			}
		}
	});

	//提交
	$("#btn_submit")
			.click(
					function() {
						if (addForm.form()) {
							$("#addForm")
									.ajaxSubmit(function(result) {
										art.dialog( {
											id : 'loading'
										}).close();//关闭等待框
											if (result == "true") {
												art
														.dialog( {

															content : "添加成功!",
															lock : true,
															ok : function() {
																location.href = "${path}/routine/daily/index/dailylist";
															},
															cancelVal : '关闭',
															cancel : function() {
																$("#affairItem")
																		.val("");
																$(
																		"#affairContent")
																		.val("");
																$("#isView")
																		.attr(
																				"checked",
																				false);
																$("#markDate")
																		.val(
																				today);
															}
														});
											} else {
												art.dialog( {
													content : "添加失败!",
													lock : true,
													ok : true
												});
											}
										});
						}
					});

	//清空
	/*
	$("#btn_clear").click(function() {
		$("#affairType option:first").attr("selected", true);
		$("#affairItem").val("");
		$("#affairContent").val("");
		$("#isView").attr("checked", false);
		$("#markDate").hide();
		$("#markDate").val(today);
	});
	 */

});
</script>
	</head>
	<body id="master">

		<sfa:mainHeader></sfa:mainHeader>

		<div class="webpart3 contentarea">
			<div class="webpart-head">
				<div class="webpart-head-item">
					新建事务
				</div>
			</div>
			<div class="webpart-main">
				<div class="webpart-main-item" style="padding: 30px;">
					<div class="d_formitem">
						<form id="addForm" action="${path}/routine/daily/index/add"
							method="post">
							<table cellspacing="0" cellpadding="0" class="formitem">
								<tr>
									<td>
										<span>营销员姓名：</span>
									</td>
									<td>
										<span class="bigspan">${UserName}</span>
									</td>
								</tr>
								<tr>
									<td>
										<span>事务类型：</span>
									</td>
									<td>
										<sfa:dic showType="select" kindNo="AFFAIRTYPE"
											attr="class='input-txt'" name="affairType" id="affairType"></sfa:dic>
									</td>
								</tr>
								<tr>
									<td>
										<span>事务标题：</span>
									</td>
									<td>
										<input type="text" id="affairItem" name="affairItem"
											class="input-txt" maxlength="20" />
									</td>
								</tr>
								<tr>
									<td>
										<span>事务内容：</span>
									</td>
									<td>
										<textarea name="affairContent"
											style="width: 300px; height: 80px;" id="affairContent"
											class="multibox"></textarea>
									</td>
								</tr>
								<tr>
									<td>
										<span>是否在日历显示：</span>
									</td>
									<td>
										<input type="checkbox" class="checkbox" id="isView"
											name="isView" value="true" checked>
									</td>
								</tr>
								<tr>
									<td></td>
									<td>
										<div id="markDiv">
											<input id="markDate" name="markDate" type="text"
												onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"
												class="Wdate" readOnly="true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
									</td>
									<td>
										<input type="button" id="btn_submit" tabindex="5"
											class="linkbtn2" value="提交">
										&nbsp;&nbsp;
										<input type="button" id="btn_back" tabindex="5"
											class="linkbtn2" value="返回"
											onclick="location.href='${path}/routine/daily/index/dailylist';">
									</td>
								</tr>
							</table>
						</form>
					</div>
				</div>
			</div>
			<div class="webpart-foot">
				<div class="webpart-foot-item">
				</div>
			</div>
		</div>






		<sfa:mainFooter></sfa:mainFooter>
	</body>
</html>


